import SwiftUI

struct MainTabView: View {
    @EnvironmentObject var expenseStore: ExpenseStore
    @EnvironmentObject var budgetStore: BudgetStore

    var body: some View {
        TabView {
            HomeView()
                .tabItem {
                    Image(systemName: "house.fill")
                    Text("Home")
                }

            AddExpenseView { newExpense in
                // Save to expense store
                expenseStore.add(newExpense)

                // Update the matching budget
                budgetStore.applyExpense(newExpense)
            }
            .tabItem {
                Image(systemName: "plus.circle.fill")
                Text("Add")
            }

            BudgetView()
                .tabItem {
                    Image(systemName: "chart.pie.fill")
                    Text("Budgets")
                }
        }
        .environmentObject(expenseStore)
        .environmentObject(budgetStore)
    }
}
